home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Collision ƒ / sApple.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-26  |  824 b   |  46 lines  |  [TEXT/KAHL]

  1. #include "SAT.h"
  2.  
  3. //• C translation from Pascal source file: sApple.p
  4.  
  5. //•  Apple sprite for SATcollision .
  6.  
  7. //• sApple;
  8.  
  9. //• Prototypes, etc.
  10.  
  11. #include "Collision.h"
  12.     
  13. Handle theSound;
  14. FacePtr appleFace;
  15.  
  16. void InitApple()
  17. {
  18.     theSound = SATGetSound(128);
  19.     appleFace = GetFace(132);
  20. }
  21.  
  22. pascal void SetupApple(SpritePtr me)
  23. {
  24.     me->speed.h = 1 + Rand(3);
  25.     me->kind = -1; //• Enemy kind.
  26.     me->face = appleFace;
  27.     SetRect(&me->hotRect, 0, 0, 32, 32);
  28.     me->task = HandleApple;
  29. }
  30.  
  31. pascal void HandleApple(SpritePtr me)
  32. {
  33.     if ( me->kind != -1 ) //• Something hit us!.
  34.     {
  35.         SATSoundPlay(theSound, 1, false);
  36.         me->task = 0L; //• Go away.
  37.     }
  38. //• Move.
  39.     me->position.h = me->position.h + me->speed.h;
  40.     if ( me->position.h > gSAT.offSizeH - 16 )
  41.         me->speed.h = -1 - Rand(3);
  42.     if ( me->position.h < -16 )
  43.         me->speed.h = 1 + Rand(3);
  44. }
  45.  
  46.